Skip to content

feat: adds HMAC authentication support for catalog remote#568

Merged
giogam merged 14 commits into
mainfrom
CLD-817/add-hmac-support-during-changeset-execution
Nov 11, 2025
Merged

feat: adds HMAC authentication support for catalog remote#568
giogam merged 14 commits into
mainfrom
CLD-817/add-hmac-support-during-changeset-execution

Conversation

@giogam

@giogam giogam commented Nov 7, 2025

Copy link
Copy Markdown
Contributor

Implements KMS-based HMAC authentication for catalog gRPC connections:

  • Add HMACAuthConfig to catalog configuration
  • Implement AWS KMS HMAC signature generation using SHA-256
  • Add HMAC signature and timestamp to gRPC metadata headers
  • Refactor catalog stores to support HMAC-enabled DataAccess calls
  • Updated CI config code

Implements KMS-based HMAC authentication for catalog gRPC connections:
- Add HMACAuthConfig to catalog configuration
- Implement AWS KMS HMAC signature generation using SHA-256
- Add HMAC signature and timestamp to gRPC metadata headers
- Refactor catalog stores to support HMAC-enabled DataAccess calls
@changeset-bot

changeset-bot Bot commented Nov 7, 2025

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: af656db

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
chainlink-deployments-framework Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@giogam giogam force-pushed the CLD-817/add-hmac-support-during-changeset-execution branch from e743263 to 9911d95 Compare November 9, 2025 11:27
@giogam giogam marked this pull request as ready for review November 9, 2025 13:07
@giogam giogam requested review from a team as code owners November 9, 2025 13:07
Comment thread datastore/catalog/remote/grpc.go Outdated

func (c *CatalogClient) DataAccess() (grpc.BidiStreamingClient[pb.DataAccessRequest, pb.DataAccessResponse], error) {
func (c *CatalogClient) DataAccess(req proto.Message) (grpc.BidiStreamingClient[pb.DataAccessRequest, pb.DataAccessResponse], error) {
if c.cachedStream == nil {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

potential race condition here, maybe we can use sync.once

func (c *CatalogClient) DataAccess(req proto.Message) (grpc.BidiStreamingClient[pb.DataAccessRequest, pb.DataAccessResponse], error) {
    c.streamInitOnce.Do(func() {
        ctx := c.ctx
        if c.hmacConfig != nil {
            var err error
            ctx, err = c.prepareHMACContext(c.ctx, req)
            if err != nil {
                c.streamInitErr = fmt.Errorf("failed to prepare HMAC context: %w", err)
                return
            }
        }

        stream, err := c.protoClient.DataAccess(ctx)
        if err != nil {
            c.streamInitErr = err
            return
        }
        c.cachedStream = stream
    })

    return c.cachedStream, c.streamInitErr
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good, point. I applied your suggestion!

ctx := c.ctx
if c.hmacConfig != nil {
var err error
ctx, err = c.prepareHMACContext(c.ctx, req)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i noticed here in preparedHMACContext, it cals config.LoadDefaultConfig( everytime, which means if we start a new stream, it has to load the default config again, i wonder if we can just do that once too?

Just playing around, maybe a bad idea haha

// Initialize KMS client once
func (c *CatalogClient) getKMSClient(ctx context.Context) (kmsClient, error) {
    c.kmsClientOnce.Do(func() {
        cfg, err := config.LoadDefaultConfig(ctx, config.WithRegion(c.hmacConfig.KeyRegion))
        if err != nil {
            c.kmsClientErr = fmt.Errorf("failed to load AWS config: %w", err)
            return
        }
        c.kmsClient = kms.NewFromConfig(cfg)
    })
    return c.kmsClient, c.kmsClientErr
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah we can write it so we ensure this runs only once. Looking at how we are using catalog client right now I don't think it would be ever loaded more than once but it's good for future upgrades

Comment thread datastore/catalog/remote/grpc.go Outdated
Comment thread datastore/catalog/remote/hmac_auth.go Outdated
Comment on lines +45 to +46
if strings.Contains(streamErr.Error(), "Unauthenticated") || strings.Contains(streamErr.Error(), "HMAC") {
t.Skipf("Catalog service at %s requires HMAC authentication. Skipping integration test.", catalogAddr)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is using contains the best way we can check?I thought dimitrios did some work on the server returning some error code?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but i guess since it is test, not super fuss if there is no better way

Comment thread engine/cld/catalog/catalog.go Outdated
The interceptors slice was declared but never populated, making the
conditional check and append operation dead code. This cleanup removes
both the unused variable declaration and the unreachable code block.
Comment thread engine/cld/config/env/config.go Outdated
Comment on lines +240 to +241
"catalog.auth.kms_key_id": {"CATALOG_AUTH_KMS_KEY_ID", "CATALOG_SERVICE_AUTH_KMS_KEY_ID"},
"catalog.auth.kms_key_region": {"CATALOG_AUTH_KMS_KEY_REGION", "CATALOG_SERVICE_AUTH_KMS_KEY_REGION"},

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need the other ones? We should just need 1 value for each mapping ? The others have 2 because of backwards compatibility.

Suggested change
"catalog.auth.kms_key_id": {"CATALOG_AUTH_KMS_KEY_ID", "CATALOG_SERVICE_AUTH_KMS_KEY_ID"},
"catalog.auth.kms_key_region": {"CATALOG_AUTH_KMS_KEY_REGION", "CATALOG_SERVICE_AUTH_KMS_KEY_REGION"},
"catalog.auth.kms_key_id": {"CATALOG_AUTH_KMS_KEY_ID"},
"catalog.auth.kms_key_region": {"CATALOG_AUTH_KMS_KEY_REGION"},

@cl-sonarqube-production

Copy link
Copy Markdown

Quality Gate failed Quality Gate failed

Failed conditions
79.5% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube

@giogam giogam added this pull request to the merge queue Nov 11, 2025
Merged via the queue into main with commit 109b6f8 Nov 11, 2025
14 of 15 checks passed
@giogam giogam deleted the CLD-817/add-hmac-support-during-changeset-execution branch November 11, 2025 12:01
github-merge-queue Bot pushed a commit that referenced this pull request Nov 12, 2025
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and the packages will
be published to npm automatically. If you're not ready to do a release
yet, that's fine, whenever you add more changesets to main, this PR will
be updated.


# Releases
## chainlink-deployments-framework@0.65.0

### Minor Changes

-
[#568](#568)
[`109b6f8`](109b6f8)
Thanks [@giogam](https://github.com/giogam)! - feat: adds HMAC
authentication support for catalog remote

-
[#559](#559)
[`57ee135`](57ee135)
Thanks [@ecPablo](https://github.com/ecPablo)! - Add support to decode
proposals that use EIP-1967 proxies

-
[#562](#562)
[`aa38817`](aa38817)
Thanks [@jkongie](https://github.com/jkongie)! - Removes the import of a
root `go.mod` from a scaffolded domain

-
[#567](#567)
[`d06057a`](d06057a)
Thanks [@JohnChangUK](https://github.com/JohnChangUK)! - Sui MCMS
upgrade

### Patch Changes

-
[#530](#530)
[`dc2c113`](dc2c113)
Thanks [@graham-chainlink](https://github.com/graham-chainlink)! - fix:
make config files and chain credentials optional

---------

Co-authored-by: app-token-issuer-engops[bot] <144731339+app-token-issuer-engops[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants